﻿namespace SampleApplication.CoffeeShopSample.Implementation.Application.CommandsParsers
{
    #region Usings

    using Dependencies.Application;
    using Dependencies.Domain;
    using System;

    #endregion Usings

    public class MakeTeaCommand : ICommand
    {
        private readonly ICoffeeShop coffeeShop;
        private readonly ITeaBagDispenser teaBagDispenser;
        private readonly IOutputWriter outputWriter;

        public MakeTeaCommand(ICoffeeShop coffeeShop, ITeaBagDispenser teaBagDispenser, IOutputWriter outputWriter)
        {
            if (coffeeShop == null) throw new ArgumentNullException("coffeeShop");
            if (teaBagDispenser == null) throw new ArgumentNullException("teaBagDispenser");
            if (outputWriter == null) throw new ArgumentNullException("outputWriter");

            this.coffeeShop = coffeeShop;
            this.teaBagDispenser = teaBagDispenser;
            this.outputWriter = outputWriter;
        }

        public void Execute()
        {
            var teaBag = teaBagDispenser.GetTeaBag();

            var cup = coffeeShop.MakeTea(teaBag);

            outputWriter.WriteLine(cup.ToString());
        }
    }
}